package com.bardpub.controls 
{
	import flash.display.MovieClip;
	import flash.display.Sprite;
	
	/**
	 * ...
	 * @author bardpub
	 */
	public class NavigationTree extends BComponent
	{
		
		private var _labels:Array;
		private var _labelsHolder:Sprite;
		public function NavigationTree() 
		{
			_labelsHolder = new Sprite();
			addChild(_labelsHolder);
			_labels = new Array();
			addItem("首页", "default");
			addItem("关于我们", "about");
			addItem("栏目二", "china");
			addItem("栏目二", "china");
			addItem("栏目二", "china");
			position();
		}
		
		public function addItem(label:String, pageName:String):NavigationElement
		{
			var elem:NavigationElement = new NavigationElement();
			elem.label = label;
			elem.pageName = pageName;
			elem.x = _labels.length * (elem.width + 2);
			_labels.push(elem);
			_labelsHolder.addChild(elem);
			
			return elem;
		}
		
		public function position():void 
		{
			var l:Number = 0;
			for (var i:int = 0, len:int = _labels.length; i < len; i++ )
			{
				l += _labels[i].width + 2;
			}
			l -= 2;
			this.x = 0;
			_labelsHolder.x = (stage.stageWidth - l) / 2;
		}
	}

}